Guided missile script by SEFE
=============================

This script allows you to fire AA and AT missiles at moving air and grund targets.

1. Features:

- AA and AG mode with different behaviour of the missiles
- Deflection shooting in AA mode
- Terrain following in AG mode
- Supports all types of missiles in both fire modes

2. Syntax:
[Target, MissileType, FiringPos, FiringDirection, FiringElevation, LockAngle, FireMode, InternalView] Exec "GuidMis.sqs"

Target: Any ground or air target
MissileType: The type of the missile you want to use. You have to set the type in quotes, e.g.: "AT3". Supported types are: LAW, RPG, CarlGustav, AT3,  AT4, Hellfire, Maverick, Ch29T (the Su25's AT-missile), Zuni (the FFAR of the Cobra and the Apache), Rocket57 (the russian 57 mm rocket), AA (the Stinger missile) and 9K32 (the Strela missile)
FiringPos: A position array containing the x-, y- and z-coordinates of the firing position.
FiringDirection: The initial direction of the fired missile before it starts homing towards the target.
FiringElevation: The initial elevation of the fired missile before it starts homing towards the target. All values between 70 and -70 are supported. 70 means that you are firing 70 degrees upwards, -70 that you are firing 70 degrees downwards an 0 that you ar firing the missile parallel to the ground.
LockAngle: The angle of the "sensetive" area of the missile. Use any values between 0 and 360. 0 would mean that the missil will not be able to lock on the target, 360 will give the missile the ability to lock on the target wherever it is. If you want to create a missile that's guidance system scans an area of 120 degress in front of it (-60 to +60 to both sides, upwards and downwards), you would use the value 120.
FireMode: TRUE for AA fire mode and FALSE for AG fire mode. In AA mode an agile missile capable of deflection shooting will be created. In AG mode the missile will be less agile, especially when moving upwards or downwards. The missile will fly in terrain following mode. That means that it will keep it's height and follow the elevation of the terrain until it's near the target. Both fire modes can be used with all type of missiles. Even unguided missiles like the FFAR will head towards the target. The missilies all have different properties like firepower or speed.
InternalView: This field set to TRUE let's you see the flight of the missile through the missile cam. All missiles (not only TV-guided missiles like the maverick) can use this feature.

3. Deflection shooting
You may have asked yourself: "what the hell is deflection shooting?". Deflection shooting gives the missile the capability to hit fast moving objects. Although less important for an AG missile, it's absolutely nescessary for AA missiles. Just imagine a fast moving plane. If the missile heads directly upon the target, it will have moved away when the missile has reached it and the it will miss the plane. To avoid that, the missile calculates where the target will be when the missile reaches it. Thus, it targets on an intercepion point right ahead of the target. Just watch the sample mission. When the A10 flies in from the west it will cause a missile to be fired on it. Watch the missile carefully; you will see it will fly to a point ahead of the target and finally hit it where it really hurts.

4. How does it work?
Since this is a very complicated script, it's impossible to explain it in detail. It uses several trigonometrical functions like Sin or ArcTan to calculate the direction of the target relative to the missile and then changing it's direction and position (a big thank you to the authors of the unofficial OFP command manual, I didn't know before that OFP supports trigonometry). To understand the script completely you have to have some knowlege in trigonometry. Please understand that I can't provide any technical support. Just try to figure it out by yourself.

Enjoy the script and the sample mission.

SEFE